#include "Pumples.h"
using namespace std;
Pumples * Pumples::create(float x)
{
  auto ptr = new(nothrow)Pumples(x);
  ptr->autorelease();
  return ptr;
}

Pumples::Pumples(float x)
{
  Layer::init();
  this->setPositionX(x);

  auto dir = Director::getInstance();
  auto vsize = dir->getVisibleSize();
  auto down = dir->getTextureCache()->addImage("res/down_bar.png");
  auto up = dir->getTextureCache()->addImage("res/up_bar.png");
  auto downBar = Sprite::createWithTexture(down);
  auto upBar = Sprite::createWithTexture(up);

  auto spSize = downBar->getContentSize();
  float maxY = spSize.height / 2;
  float minY = -spSize.height / 4;

  float y;
  y = random(minY, maxY);

  downBar->setPositionY(y);
  upBar->setPositionY( y + spSize.height + vsize.width / 3);

  this->addChild(downBar, 2 ,"up");
  this->addChild(upBar, 2,"down");
}

void Pumples::onEnter()
{
  Layer::onEnter();
}

